From dfa894b76ee3584bf169710c78c57330c5d6ee67 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Wed, 29 Nov 2023 12:28:03 +0100 Subject: fix(pages,services): make thematics & topics pages usable again When I refactored the fetchers and convertors in #f111685 I forgot to convert WPThematicPreview and WPTopicPreview so the thematics and topics pages was broken. I also: * removed the ToC added by error in #70b4f63 * fix heading styles * fix website url in topics pages --- src/pages/thematique/[slug].tsx | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) (limited to 'src/pages/thematique/[slug].tsx') diff --git a/src/pages/thematique/[slug].tsx b/src/pages/thematique/[slug].tsx index f8c3404..9ea52e1 100644 --- a/src/pages/thematique/[slug].tsx +++ b/src/pages/thematique/[slug].tsx @@ -13,11 +13,11 @@ import { Page, PageHeader, PageSidebar, - TocWidget, PageBody, } from '../../components'; import { - convertTaxonomyToPageLink, + convertWPThematicPreviewToPageLink, + convertWPThematicToThematic, fetchAllThematicsSlugs, fetchThematic, fetchThematicsCount, @@ -35,7 +35,7 @@ import { getWebPageSchema, } from '../../utils/helpers'; import { loadTranslation, type Messages } from '../../utils/helpers/server'; -import { useBreadcrumb, useHeadingsTree } from '../../utils/hooks'; +import { useBreadcrumb } from '../../utils/hooks'; export type ThematicPageProps = { currentThematic: Thematic; @@ -48,13 +48,12 @@ const ThematicPage: NextPageWithLayout = ({ thematics, }) => { const { content, intro, meta, slug, title } = currentThematic; - const { articles, dates, seo, topics } = meta; + const { articles, dates, seo, relatedTopics } = meta; const intl = useIntl(); const { items: breadcrumbItems, schema: breadcrumbSchema } = useBreadcrumb({ title, url: `${ROUTES.THEMATICS.INDEX}/${slug}`, }); - const { ref, tree } = useHeadingsTree({ fromLevel: 2 }); const { asPath } = useRouter(); const webpageSchema = getWebPageSchema({ @@ -87,11 +86,6 @@ const ThematicPage: NextPageWithLayout = ({ id: '/42Z0z', }); const pageUrl = `${CONFIG.url}${asPath}`; - const tocTitle = intl.formatMessage({ - defaultMessage: 'Table of Contents', - description: 'PageLayout: table of contents title', - id: 'eys2uX', - }); return ( @@ -127,13 +121,7 @@ const ThematicPage: NextPageWithLayout = ({ updateDate: dates.update, }} /> - - {tocTitle}} - tree={tree} - /> - - + {/*eslint-disable-next-line react/no-danger -- Necessary for content*/}
{articles ? ( @@ -166,14 +154,14 @@ const ThematicPage: NextPageWithLayout = ({ } items={getLinksItemData(thematics)} /> - {topics ? ( + {relatedTopics ? ( {topicsListTitle} } - items={getLinksItemData(topics)} + items={getLinksItemData(relatedTopics)} /> ) : null} @@ -197,7 +185,7 @@ export const getStaticProps: GetStaticProps = async ({ first: totalThematics, }); const allThematics = allThematicsEdges.edges.map((edge) => - convertTaxonomyToPageLink(edge.node) + convertWPThematicPreviewToPageLink(edge.node) ); const allThematicsLinks = allThematics.filter( (thematic) => @@ -208,7 +196,9 @@ export const getStaticProps: GetStaticProps = async ({ return { props: { - currentThematic: JSON.parse(JSON.stringify(currentThematic)), + currentThematic: JSON.parse( + JSON.stringify(convertWPThematicToThematic(currentThematic)) + ), thematics: JSON.parse(JSON.stringify(allThematicsLinks)), translation, }, -- cgit v1.2.3